Skip to main content

Unit Class

Description:

  A class for creating instances of Unit.

GroundSensorTag

Type: Readonly Field.

Description:

  The tag for the "GroundSensor" attached to each "Unit".

Signature:

const GroundSensorTag: integer

DetectSensorTag

Type: Readonly Field.

Description:

  The tag for the "DetectSensor" attached to each "Unit".

Signature:

const DetectSensorTag: integer

AttackSensorTag

Type: Readonly Field.

Description:

  The tag for the "AttackSensor" attached to each "Unit".

Signature:

const AttackSensorTag: integer

__call

Type: Metamethod.

Description:

  A metamethod that creates a new "Unit" object.

Signature:

metamethod __call: function(
self: UnitClass,
unitDef: Dictionary,
physicsWorld: PhysicsWorld,
entity: Entity,
pos: Vec2,
rot?: number --[[0.0]]
): Unit

Parameters:

ParameterTypeDescription
unitDefDictionaryA "Dictionary" object that defines the properties and behavior of the "Unit".
physicsWorldPhysicsWorldA "PhysicsWorld" object that represents the physics simulation world.
entityEntityAn "Entity" object that represents the "Unit" in ECS system.
posVec2A "Vec2" object that specifies the initial position of the "Unit".
rotnumber[optional] An optional number that specifies the initial rotation of the "Unit" (default is 0.0).

Returns:

Return TypeDescription
UnitThe newly created "Unit" object.

__call

Type: Metamethod.

Description:

  A metamethod that creates a new "Unit" object.

Signature:

metamethod __call: function(
self: UnitClass,
unitDefName: string,
physicsWorldName: string,
entity: Entity,
pos: Vec2,
rot?: number --[[0.0]]
): Unit

Parameters:

ParameterTypeDescription
unitDefNamestringA string that specifies the name of the "Unit" definition to retrieve from Data.store table.
physicsWorldNamestringA string that specifies the name of the "PhysicsWorld" object to retrieve from Data.store table.
entityEntityAn "Entity" object that represents the "Unit" in ECS system.
posVec2A "Vec2" object that specifies the initial position of the "Unit".
rotnumber[optional] An optional number that specifies the initial rotation of the "Unit" (default is 0.0).

Returns:

Return TypeDescription
UnitThe newly created "Unit" object.